home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / scheme / gjr / cmplrtst.lha / bitwse.scm < prev    next >
Encoding:
Text File  |  1991-02-25  |  1.5 KB  |  97 lines

  1. ;;; -*- Scheme -*-
  2.  
  3. #|
  4. Description:
  5.  
  6. This code tests fixnum binary arithmetic and division:
  7. The procedures may be open-coded, or special utilities
  8. may be used instead.
  9.  
  10. Usage:
  11. Try each of them as if they were fix:lsh, etc., etc.
  12. Make sure, in particular, that quotient and lsh work for negative
  13. arguments:
  14.  
  15. (my-quotient -1 4) -> 0
  16. (my-lsh -1 -2) -> <a positive number>
  17.  
  18. |#
  19.  
  20. (declare (usual-integrations))
  21.  
  22. (define (my-lsh x y)
  23.   (fix:lsh x y))
  24.  
  25. (define (my-lsh-6 x)
  26.   (fix:lsh x -6))
  27.  
  28. (define (my-lsh+6 x)
  29.   (fix:lsh x 6))
  30.  
  31. (define (my-lsh*6 x)
  32.   (fix:lsh 6 x))
  33.  
  34. (define (my-quotient x y)
  35.   (fix:quotient x y))
  36.  
  37. (define (my-quotient-64 x)
  38.   (fix:quotient x -64))
  39.  
  40. (define (my-quotient+64 x)
  41.   (fix:quotient x 64))
  42.  
  43. (define (my-quotient*64 x)
  44.   (fix:quotient 64 x))
  45.  
  46. (define (my-remainder x y)
  47.   (fix:remainder x y))
  48.  
  49. (define (my-remainder-64 x)
  50.   (fix:remainder x -64))
  51.  
  52. (define (my-remainder+64 x)
  53.   (fix:remainder x 64))
  54.  
  55. (define (my-remainder*64 x)
  56.   (fix:remainder 64 x))
  57.  
  58. ;; Bitwise
  59.  
  60. (define (my-not x)
  61.   (fix:not x))
  62.  
  63. (define (my-and x y)
  64.   (fix:and x y))
  65.  
  66. (define (my-and/c x)
  67.   (fix:and #b101010101 x))
  68.  
  69. (define (my-and\c x)
  70.   (fix:and x #b101010101))
  71.  
  72. (define (my-andc x y)
  73.   (fix:andc x y))
  74.  
  75. (define (my-andc/c x)
  76.   (fix:andc #b101010101 x))
  77.  
  78. (define (my-andc\c x)
  79.   (fix:andc x #b101010101))
  80.   
  81. (define (my-or x y)
  82.   (fix:or x y))
  83.  
  84. (define (my-or/c x)
  85.   (fix:or #b101010101 x))
  86.  
  87. (define (my-or\c x)
  88.   (fix:or x #b101010101))
  89.  
  90. (define (my-xor x y)
  91.   (fix:xor x y))
  92.  
  93. (define (my-xor/c x)
  94.   (fix:xor #b101010101 x))
  95.  
  96. (define (my-xor\c x)
  97.   (fix:xor x #b101010101))